package com.ciwong.epaper.modules.epaper.adapter;

import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ListAdapter;
import android.widget.TextView;

import com.ciwong.epaper.R;
import com.ciwong.epaper.modules.epaper.bean.ChooseGradeBean;
import com.ciwong.epaper.modules.me.adapter.BaseCommonAdapter;

import java.util.List;

/**
 * Created by yyf on 2017/8/17.
 */

public class ChooseGradeAdapter extends BaseCommonAdapter {
    public ChooseGradeAdapter(List<ChooseGradeBean> dataList) {
        super(dataList);
    }

    @Override
    public int getItemResId(int position) {
        return R.layout.item_choose_grade;
    }

    @Override
    public Object createViewHolder(View convertView, int position) {
        ViewHolder viewHolder = new ViewHolder();
        viewHolder.tv_icon = (TextView) convertView.findViewById(R.id.tv_icon);
        viewHolder.tv_title = (TextView) convertView.findViewById(R.id.tv_title);
        return viewHolder;
    }

    @Override
    public void showData(Object bean, Object holder, int position) {
        ViewHolder viewHolder = (ViewHolder) holder;
        ChooseGradeBean chooseGradeBean = (ChooseGradeBean) bean;
        viewHolder.tv_icon.setText(chooseGradeBean.icon);
        viewHolder.tv_title.setText(chooseGradeBean.title);
        if (chooseGradeBean.title.equals("其他")) {
            viewHolder.tv_icon.setBackgroundResource(R.drawable.icon_choose_grade_other);
        } else {
            viewHolder.tv_icon.setBackgroundResource(R.drawable.icon_choose_grade);

        }
    }

    class ViewHolder {
        public TextView tv_icon;
        public TextView tv_title;
    }
}
